package com.ruoyi.channel.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 渠道/产品计价类型
 */
@Getter
public enum ChannelTypeEnum {

    TEST("TEST", "审核渠道"),
//    DC("DC", "贷超"),
    ZD("ZD", "助贷")
    ;

    private String value;
    private String name;

    ChannelTypeEnum(String value, String name){
        this.value = value;
        this.name = name;
    }

    public static List<Map<String, String>> getChannelTypeMapList(){
        List<Map<String, String>> resultList = new ArrayList<>();
        for (ChannelTypeEnum channelTypeEnum : values()) {
            Map<String, String> itemMap = new HashMap<>();
            itemMap.put("key", channelTypeEnum.getName());
            itemMap.put("value", String.valueOf(channelTypeEnum.getValue()));
            resultList.add(itemMap);
        }
        return resultList;
    }

    public static String getNameByValue(String channelType) {
        for (ChannelTypeEnum channelTypeEnum : values()) {
            if (ObjectUtil.equals(channelType, channelTypeEnum.getValue())){
                return channelTypeEnum.getName();
            }
        }
        return String.valueOf(channelType);
    }

    public static String getValueByName(String value) {
        for (ChannelTypeEnum typeEnum : values()) {
            if (ObjectUtil.equals(value, typeEnum.getValue())){
                return typeEnum.getName();
            }
        }
        return String.valueOf(value);
    }

    public static String getNameByValues(String name) {
        for (ChannelTypeEnum typeEnum : values()) {
            if (ObjectUtil.equals(name, typeEnum.getName())){
                return typeEnum.getValue();
            }
        }
        return String.valueOf(name);
    }

}
